#include <stdio.h>
#include <stdlib.h>
#include <string.h>


struct tt 
{
	char a;
	void *private_data;
};

struct wd
{
	char a;
	int b;
	int c;
	struct tt t;
};

int test(struct tt *ts)
{
//	struct tt *t;
	struct wd *w;
	char *p;
	
	ts->a = 'a';
	ts->private_data = "wiaozhi_1234567890";
	
	//w = (struct wd *)t->private_data;
	w = ts->private_data;
	p = ts->private_data;
	
	printf("%c %c %c %c %s\n", w->a, w->b, w->c, w->t.a, p);
	
	return 0;
}

int (*pf)(void);

int f(void)
{
	printf("================= wise\n");
	return 1;
}

void test_pf()
{
	pf = &f;
	pf();

	pf = f;
	pf();

	pf = ****f;
	pf();

	(***************************************************f)();	// 任何函数都可以这样调用.
}

int re()
{
	return ((int []){1,2,3,4})[3];	// 4.    ((int []){1,2,3,4})[2] = 3; []前面为数组,[]里为数组标号
}

unsigned long foo()
{
	printf("\t=========== %ld\n", (unsigned long) - 1);	// -1
	printf("\t--------11= %ld\n", (-1 / 8));	// 0

	printf("\t--------(-1)= %ld\n", ((unsigned int)(-1)));	// -1
	printf("\t--------(-1)= %ld\n", ((unsigned int)(-1))+1);	// 0
	printf("\t--------( 0)= %ld\n", ((unsigned int)(0)));	// 0
	return (unsigned long) - 1 / 8;			// 536870911	0x1FFFFFFF
}

unsigned long foo2()
{
	return ((unsigned long) - 1) / 8;		// 536870911	0x1FFFFFFF
}

unsigned long foo3()
{
	return (unsigned long) (-1 / 8);		// 0
}

/**********************************************************************/
typedef struct 
{
	char *key;
	char *value;
}T1;

typedef struct
{
	long type;
	char *value;
}T3;

T1 a[] = {
			{
				"",
				((char *)&((T3) {1, (char *) 1}))
			}
		};
		
int T()
{
	T3 *pt3 = (T3*)a[0].value;
	int value;
	char *b = "xiaozhi";
	char c[] = {'a', 'b', 'c', 'd', 'e', 'f'};
	
	value = sizeof(a);
	printf("T() : %d %d %d %d sizeof c=%d strlen c=%d\n", 
					 value, sizeof(long),
					 sizeof(b), strlen(b), 
					 sizeof(c), strlen(c));
	return (int)pt3->value;
}
/********************************************************************/

int xxx = 7;
int fxxx()
{
	int xxx = 3;
	{
		extern int xxx;
		return xxx;	// 7
	}
}

int iii()
{
	return ((1 - sizeof(int)) >> 31);	// 1
}


void point_to_long(char *name)
{
	unsigned long addr;

	addr = (unsigned long)name;
}

struct 
{
	int x;
	struct 
	{
		int y, z;
	}nested;
} ix = { .nested.y = 5, 6, .x = 1, 2};

void invoke()
{
	printf("invoke re   ======== %ld\n",  re());		// 4
	printf("invoke foo  ======== %ld\n", foo());	// 536870911 
	printf("invoke foo2 ======== %ld\n", foo2());	// 536870911 
	printf("invoke foo3 ======== %ld\n", foo3());	// 0
	printf("invoke iii    ======== %ld\n", iii());	// 1
	printf("invoke fxxx    ======== %ld\n", fxxx());	// 7
}

int main()
{

	test_pf();
	(***************************test_pf)();	// 两种不同的调用方式.效果相同.
	invoke();
	
	return 0;
}


